{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4a23a9d9-5123-479f-b164-e1a0572bc861",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_openai import ChatOpenAI\n",
    "from dotenv import load_dotenv\n",
    "assert load_dotenv()\n",
    "llm = ChatOpenAI(model='gpt-4o-mini')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cbefe874-c7c0-4c5b-bce6-b4111cadd7fa",
   "metadata": {},
   "source": [
    "### prebuilt"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a140f952-5530-4fc6-b413-8af514237af9",
   "metadata": {},
   "source": [
    "```python\n",
    "from langgraph.prebuilt import create_react_agent\n",
    "\n",
    "# Pass in:\n",
    "# (1) the augmented LLM with tools\n",
    "# (2) the tools list (which is used to create the tool node)\n",
    "pre_built_agent = create_react_agent(llm, tools=tools)\n",
    "\n",
    "# Show the agent\n",
    "display(Image(pre_built_agent.get_graph().draw_mermaid_png()))\n",
    "\n",
    "# Invoke\n",
    "messages = [HumanMessage(content=\"Add 3 and 4.\")]\n",
    "messages = pre_built_agent.invoke({\"messages\": messages})\n",
    "for m in messages[\"messages\"]:\n",
    "    m.pretty_print()\n",
    "```"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
